extends Node2D


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	GameUtiles.player_bag = {}
	GameUtiles.ingredients = []
	
	$map/bridge.hide()
	
	
	
	
	

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if GameUtiles.l3_biult == true:
		$map/bridge.show()
		
	if not GameUtiles.cloudmaking:
		$items/cloudmaking.hide()
	else:
		$items/cloudmaking.show()
		
		
		

func _on_body_entered(body: Node2D) -> void:
	if body.name =="player" and GameUtiles.move_allow and GameUtiles.l3_biult:
		print("3to3.5")
		get_tree().change_scene_to_file("res://scenes/level_3_5.tscn")
		
		
var player_in_range:bool=false
#造桥判定
func _on_area_2d_body_entered(body: Node2D) -> void:
	if body.name =="player":
		player_in_range=true
		
func _on_area_2d_body_exited(body: Node2D) -> void:
	if body.name =="player":
		player_in_range=false

func _input(event):
	if not GameUtiles.l3_biult:
		if event.is_action_pressed("build") and player_in_range and GameUtiles.move_allow:
			if GameUtiles.player_bag.get("sti_ste_holdfan",0) > 0 or GameUtiles.ingredients.has("sti_ste_holdfan"):
				DialogueManager.show_dialogue_balloon(load("res://dialogues/dia_in_levels/l3_build_bridge.dialogue"),"start")
				
		if event.is_action_pressed("build") and not player_in_range and GameUtiles.move_allow:
			print("不在监测点")
